package db;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class AttributeEntity extends Entity {

	public AttributeEntity() {
		super();
	}

	public AttributeEntity(int id) {
		super(id);
	}

	public String getValue() {
		return _value;
	}

	private String _value;

	private boolean _multiVal;

	private String _name;

	public String get_name() {
		return _name;
	}

	public boolean isMultiVal() {
		return _multiVal;
	}

	@Override
	protected Entity mapToObj(ResultSet rs) {
		AttributeEntity ie = new AttributeEntity();
		try {
			ie._id = rs.getInt("att_id");
			ie._name = rs.getString("att_name");
			ie._multiVal = rs.getBoolean("att_multivalue");

		} catch (Exception e) {
			e.printStackTrace();
		}

		return ie;
	}

	@Override
	protected void fillPreparedParams(PreparedStatement ps) {
		try {
			ps.setObject(1, "att_name");
			ps.setObject(2, _name);
			ps.setObject(3, "att_multivalue");
			ps.setObject(4, _multiVal);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	@Override
	protected String getIdCol() {
		return "att_id";
	}

	@Override
	protected int getNoCols() {
		return 2;
	}

	@Override
	protected String getTblname() {
		return "attributes";
	}

}
